#ifndef __WIZ_VFS_BLOCKSTORAGE_BLOCK_HPP__SHANHAOBO_19800429__
#define __WIZ_VFS_BLOCKSTORAGE_BLOCK_HPP__SHANHAOBO_19800429__

#include "../../../Include/Core/Accessor/WizAccessor.hpp"
#include "../../../Include/Core/File/WizFile.hpp"

#include "./WizVFSBlockStorageParam.hpp"

namespace Wiz
{
    namespace VFS
    {
        namespace BlockStorage
        {
            /// Declare
            struct Type;

            namespace Block
            {
                struct Type : public ::Wiz::VFS::BlockStorage::BlockWriteBack::Type
                {
                    typedef ::Wiz::VFS::BlockStorage::BlockWriteBack::Type tSuper;
                    Type()
                    {
                    }
                    Type(tSuper& InS) : tSuper(InS)
                    {
                    }

                    ::Wiz::UInt32::Type Write(::Wiz::VFS::BlockStorage::Param::InOut);
                    ::Wiz::Void::Type   Read(::Wiz::VFS::BlockStorage::Param::InOut);

                    ::Wiz::Void::Type SetPosition(
                        ::Wiz::UInt::In ChunkPosition,
                        ::Wiz::UInt::In BlockID,
                        ::Wiz::UInt::In BlockCompleteSize
                        )
                    {
                        m_Position =
                            ChunkPosition +
                            sizeof(::Wiz::VFS::BlockStorage::ChunkInfo::Type) +
                            BlockID * BlockCompleteSize;
                    }
                    ::Wiz::Void::Type SetPosition(
                        ::Wiz::UInt::In ChunkID,
                        ::Wiz::UInt::In ChunkCompleteSize,
                        ::Wiz::UInt::In BlockID,
                        ::Wiz::UInt::In BlockCompleteSize
                        )
                    {
                        m_Position =
                            sizeof(::Wiz::VFS::BlockStorage::StorageInfo::Type) +
                            ChunkID * ChunkCompleteSize +
                            sizeof(::Wiz::VFS::BlockStorage::ChunkInfo::Type) +
                            BlockID * BlockCompleteSize;
                    }
                public:
                    friend struct ::Wiz::VFS::BlockStorage::Type;
                    ::Wiz::UInt32::Type ReadNextAvailableBlock(::Wiz::VFS::BlockStorage::Param::InOut);
                    ::Wiz::Void::Type   WriteInfoAndAdvance(::Wiz::VFS::BlockStorage::Param::InOut);
                    ::Wiz::Void::Type   ReadInfoAndAdvance(::Wiz::VFS::BlockStorage::Param::InOut);
                };
            } /// end of namespace Block
        } /// end of namespace BlockStorage
    } /// end of namespace VFS
} /// end of namespace Wiz


#endif /*__WIZ_VFS_BLOCKSTORAGE_BLOCK_HPP__SHANHAOBO_19800429__*/
